#include "Point.h"

namespace common {

Point::Point():Vector(),IdAble() {

	anchor = new Vector();
}

void Point::setAnchor(const Vector& vector) {
	anchor = new Vector(vector);
}

Point::Point(int id,skreal x,skreal y):Vector(x, y),IdAble(id) {
//	this->id = id;
	anchor = new Vector(x,y);
}

Point::Point(int id,const Vector& vector):Vector(vector.getX(), vector.getY()),IdAble(id) {

	this->anchor->setX(vector.getX());
	this->anchor->setY(vector.getY());
}

Vector Point::getAnchor() const {
	return *anchor;
}
Vector* Point::getAnchorRef() {

	return anchor;
}

std::string Point::toString(void){
	std::stringstream os;
	os << "p"<< getId() <<"-[ " << getX() << ", " << getY()
			<< " ] , pa = { " << getAnchor().getX() << ", "
			<< getAnchor().getY() << " }" ;
	return os.str();
}

void Point::resetAnchor() {

	anchor->setX(x);
	anchor->setY(y);
}

std::istream& operator>>(std::istream& is, Point& point) {

	skreal x, y;
	is >> x;
	point.setX(x);
	is >> y;
	point.setY(y);
	point.resetAnchor();
	return is;
}
Point::~Point() {
	delete anchor;
}

}
